package com.platform.sms;

import com.platform.oss.*;
import com.platform.service.SysConfigService;
import com.platform.utils.ConfigConstant;
import com.platform.utils.Constant;
import com.platform.utils.SpringContextUtils;

/**
 * @Description: java类作用描述
 * @Author: jf2
 * @CreateDate: 2018/5/25 0025 12:06
 * @Version: 1.0
 * Copyright: Copyright (c) 2018
 **/
public class SmsFactory {

    private static SysConfigService sysConfigService;

    static {
        SmsFactory.sysConfigService = (SysConfigService) SpringContextUtils.getBean("sysConfigService");
    }

    public static SmsSendService build() {
        //获取配置信息
        SmsSendConfig config = sysConfigService.getConfigObject(ConfigConstant.SMS_CONFIG_KEY, SmsSendConfig.class);

        if (config.getType() == Constant.SmsService.CHUANGRUI.getValue()) {
            return new SmsSendChuangruiService(config);
        } else if (config.getType() == Constant.SmsService.KINGTOO.getValue()) {
            return new SmsSendKingtooService(config);
        }

        return null;
    }
}